home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Movie Toolbox / Burnt Text Sample Code / TextConverterMain.c < prev   
Encoding:
C/C++ Source or Header  |  1994-12-09  |  4.2 KB  |  158 lines  |  [TEXT/KAHL]

  1. /* Sample program that demonstrates creating "burnt" text tracks for a QuickTime movie. 
  2.     The program puts up a file dialog. The user selects a text track movie to be converted.
  3.     A second dialog then appears asking for a destination movie file as well as giving the
  4.     user some options for selecting anti-alias, drop shadow, and what compressor to
  5.     use for the burnt text. The default is the graphics compressor.
  6. */
  7.  
  8. #include <Movies.h>
  9. #include <ImageCompression.h>
  10. #include <QuickTimeComponents.h>
  11. #include "ConvertTextMovie.h"
  12.  
  13. pascal short SaveDialogHook(short item, DialogPtr dlg, void *myData);
  14. pascal void Doit(FSSpec *srcFileSpec);
  15.  
  16. Boolean gDoAntiAlias;
  17. Boolean gDoDropShadow;
  18. Boolean gImageTrack;
  19. SCSpatialSettings gSpatial;
  20.  
  21. void main(void)
  22. {
  23.     FSSpec srcFileSpec;
  24.     Point where;
  25.     SFTypeList types;
  26.     SFReply reply;
  27.     
  28.     InitGraf(&thePort);
  29.     InitFonts();
  30.     InitWindows();
  31.     InitMenus();
  32.     TEInit();
  33.     InitDialogs(0L);
  34.     InitCursor();
  35.     MaxApplZone();
  36.  
  37.     EnterMovies();
  38.  
  39.     gDoAntiAlias = false;
  40.     gDoDropShadow = false;
  41.     gImageTrack = false;
  42.  
  43.     types[0] = MovieFileType;
  44.     where.h = where.v = -2;
  45.     // The prompt field is ignored - isn't that swell?
  46.     SFGetFilePreview(where, (StringPtr)"\pPick a Text Track Movie", 0, 2, types, 0, &reply);
  47.     if (!reply.good) goto bail;
  48.         
  49.     FSMakeFSSpec(reply.vRefNum, 0, reply.fName, &srcFileSpec);
  50.  
  51.     Doit(&srcFileSpec);
  52.  
  53. bail:
  54.     ExitMovies();
  55. }
  56.  
  57.  
  58. pascal void ChooseCompressor(void);
  59. pascal void ChooseCompressor(void)
  60. {
  61.     ComponentInstance ci = 0;
  62.     Point pt;
  63.     OSErr err;
  64.     
  65.     ci = OpenDefaultComponent(StandardCompressionType,StandardCompressionSubType);
  66.     if (!ci) return;
  67.  
  68.     SCSetInfo(ci,scSpatialSettingsType,&gSpatial);
  69.     pt.h = pt.v = -1;
  70.     SCSetInfo(ci,scWindowPositionType,&pt);
  71.     err = SCRequestImageSettings(ci);
  72.     if (err == 0)
  73.         SCGetInfo(ci,scSpatialSettingsType,&gSpatial);
  74.     
  75.     if (ci) CloseComponent(ci);
  76. }
  77.  
  78. #define kSaveDialogID (456)
  79. #define kAntiAliasCheckBox (13)
  80. #define kDropShadowCheckBox (14)
  81. #define kImageTrackCheckBox (16)
  82. #define kCompressionBtn (17)
  83.  
  84. pascal short SaveDialogHook(short item, DialogPtr dlg, void *myData)
  85. {
  86.     Handle        itemToChange;    /* needed for GetDItem and SetCtlValue */
  87.     Rect        itemBox;        /* needed for GetDItem */
  88.     short        itemType;        /* needed for GetDItem */
  89.     
  90.     if (GetWRefCon(dlg) == sfMainDialogRefCon)
  91.         {
  92.         if (item == sfHookFirstCall)
  93.             {
  94.             GetDItem( dlg, kAntiAliasCheckBox, &itemType, (Handle*)&itemToChange, &itemBox);
  95.             SetCtlValue( (ControlHandle)itemToChange, gDoAntiAlias);
  96.             GetDItem( dlg, kDropShadowCheckBox, &itemType, (Handle*)&itemToChange, &itemBox);
  97.             SetCtlValue( (ControlHandle)itemToChange, gDoDropShadow);
  98.             } 
  99.         else if (item == kAntiAliasCheckBox)
  100.             {
  101.             GetDItem( dlg, item, &itemType, (Handle*)&itemToChange, &itemBox);
  102.             gDoAntiAlias = !GetCtlValue((ControlHandle)itemToChange);
  103.             SetCtlValue( (ControlHandle)itemToChange, gDoAntiAlias);
  104.             }
  105.         else if (item == kDropShadowCheckBox)
  106.             {
  107.             GetDItem( dlg, item, &itemType, (Handle*)&itemToChange, &itemBox);
  108.             gDoDropShadow = !GetCtlValue((ControlHandle)itemToChange);
  109.             SetCtlValue( (ControlHandle)itemToChange, gDoDropShadow);
  110.             }
  111.         else if (item == kImageTrackCheckBox)
  112.             {
  113.             GetDItem( dlg, item, &itemType, (Handle*)&itemToChange, &itemBox);
  114.             gImageTrack = !GetCtlValue((ControlHandle)itemToChange);
  115.             SetCtlValue( (ControlHandle)itemToChange, gImageTrack);
  116.             }
  117.         else if (item == kCompressionBtn)
  118.             {
  119.             ChooseCompressor();
  120.             }
  121.         }
  122. bail:
  123.     return item;
  124. }
  125.  
  126. pascal void Doit(FSSpec *srcFileSpec)
  127. {
  128.     SFTypeList types;
  129.     Str255 newName;
  130.     FSSpec dstFileSpec;
  131.     Point where;
  132.     StandardFileReply sfr;
  133.     long displayFlags = 0;
  134.  
  135.     gSpatial.codecType = 'smc ';
  136.     gSpatial.codec = 0;
  137.     gSpatial.depth = 8;
  138.     gSpatial.spatialQuality = 1023;
  139.  
  140.     types[0] = MovieFileType;
  141.     where.h = where.v = -1;
  142.  
  143.     BlockMove(srcFileSpec->name, newName, srcFileSpec->name[0]+1);
  144.     BlockMove("(Bitmap)", &newName[newName[0]+1], 8);
  145.     newName[0] += 8;
  146.  
  147.     CustomPutFile((StringPtr)"\pName the destination movie", newName, &sfr, kSaveDialogID, where, SaveDialogHook,
  148.                               nil, (short *)nil, (ActivateYDProcPtr)nil, (void *)nil);
  149.     if (!sfr.sfGood) return;
  150.  
  151.     if (gDoAntiAlias) displayFlags |= dfAntiAlias;
  152.     if (gDoDropShadow) displayFlags |= dfDropShadow;
  153.     
  154.     ConvertMovie(srcFileSpec, &sfr.sfFile, displayFlags, gImageTrack, &gSpatial);
  155. }
  156.  
  157.  
  158.